package routes

import (
	"baize/app/Controllers"
	"baize/app/Loginc"
	"baize/app/Middleware"
	"github.com/gin-gonic/gin"
)

func InitRouter() *gin.Engine {
	r := gin.Default()
	// web路由
	r.GET("/health/check", Controllers.Home)

	v1 := r.Group("v1")
	{
		v1.POST("/login", Loginc.Login)
		v1.POST("/register", Loginc.Register)
	}

	// 简单的路由组: v1
	Api := v1.Group("/api")
	Api.Use(Middleware.JWTAuth())
	{
		Api.GET("/ping", Controllers.Ping)
		Api.POST("/user/create", Controllers.UserCreate)
		Api.POST("/user/delete/:id", Controllers.UserDestroy)
		Api.POST("/user/update/:id", Controllers.UserUpdate)
		Api.POST("/users", Controllers.UserFindAll)
	}

	return r
}
